package com.jstyle.jclife.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.jstyle.jclife.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2019/4/1.
 */

public class EcgShowAdapter extends RecyclerViewBaseAdapter<Integer> {

    int checkPosition=0;
    private int size;
    public EcgShowAdapter(Integer integer) {
        super(integer);
        size=integer;
    }
    public void setCheckPosition(int postion){
        this.checkPosition=postion;
        notifyDataSetChanged();
    }

    @Override
    protected void bindData(BaseViewHolder holder, int position) {
        EcgHolder ecgHolder=(EcgHolder)holder;
        ecgHolder.iv_show.setImageResource(position==checkPosition?R.drawable.item_ecg_show_selected:R.drawable.item_ecg_show);
    }

    @Override
    public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext()).inflate(getLayoutId(viewType),parent,false);
        return new EcgHolder(view);
    }

    public class  EcgHolder extends BaseViewHolder{
        @BindView(R.id.iv_ecgadapter_show)
        ImageView iv_show;
        public EcgHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
    @Override
    protected int getLayoutId(int viewType) {
        return R.layout.item_ecg_show;
    }

    @Override
    public int getItemCount() {
        return size;
    }
}
